<%-- 
    Document   : order
    Created on : 19-Jul-2013, 16:33:21
    Author     : MrMAD
--%>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page import="mybean.Order"%>
<%@page import="java.util.List"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>BookStore Manager</title>    
        <link rel="stylesheet" href="../MyCss/admin.css"/>
    </head>
    <body>     
        <script src="../js/admin.js"></script>

        <h1>Order Manager</h1>
        <div><a href="logout.jsp" style="font-size: 15px;">Log out</a></div>
        <hr/>
        <%
            Order order = new Order();
            List<Order> orderList = order.getOrder();
        %>
        <br>
        <table>
            <tr>
                <th>ID</th>
                <th>Email</th>
                <th>Books</th>
                <th>Quantity</th>
                <th>Cash</th>
                <th>Status</th>
                <th>Action</th>
            </tr>
            <%
                for (int i = 0; i < orderList.size(); i++) {
            %>

            <tr>
                <td style="border-left: none;"><%= orderList.get(i).getId()%></td>
                <td><%= orderList.get(i).getEmail()%></td>
                <td><%= orderList.get(i).getBooks()%></td>
                <td><%= orderList.get(i).getTotalQuantity()%></td>
                <td><%= orderList.get(i).getTotalCash()%></td>
                <td>
                    <select id="<%= orderList.get(i).getId()%>" onchange="update(<%= orderList.get(i).getId()%>)">
                        <%
                            String status = orderList.get(i).getStatus();
                            String waiting = "", doing = "", done = "";
                            if (status.equals("Waiting")) {
                                waiting = "selected";
                            } else if (status.equals("Doing")) {
                                doing = "selected";
                            } else {
                                done = "selected";
                            }
                        %>
                        <option value="waiting" <%= waiting%>>Waiting</option>
                        <option value="doing" <%= doing%>>Doing</option>
                        <option value="done" <%= done%>>Done</option>
                    </select>
                </td>
                <td><a href="order_detail.jsp?id=<%= orderList.get(i).getId()%>">Detail</a>||<a href="order_delete_confirm.jsp?id=<%= orderList.get(i).getId()%>">Delete</a></td>
            </tr>

            <%  }
            %>

        </table>
    </body>
</html>
